import 'dart:ui';

import 'package:flutter/material.dart';

import '../shared/shared.dart';

class Background extends StatelessWidget {
  final String imageURL;
  final double opacity;
  final double filter;

  final double height;

  const Background(
      {Key? key,
      required this.imageURL,
      this.opacity = 1.0,
      this.filter = 4,
      this.height = double.infinity})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Container(
            constraints:
                BoxConstraints(minHeight: height, minWidth: double.infinity),
            decoration:
                const BoxDecoration(color: ColorConstants.primaryColor)),
        Opacity(
            opacity: opacity,
            child: Container(
                constraints: const BoxConstraints(
                    minHeight: double.infinity, minWidth: double.infinity),
                child: Image.asset(imageURL, fit: BoxFit.fitHeight))),
        Positioned.fill(
            child: BackdropFilter(
                filter: ImageFilter.blur(sigmaX: filter, sigmaY: filter),
                //可以看源码
                child: Container(
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(20)))))
      ],
    );
  }
}
